﻿#pragma once
#define LK_WINDOWS_UI_LABEL_
namespace LK
{
	namespace Windows
	{
		namespace UI
		{
			/**
			@brief 表示一个标签控件*/
			class ILabel :public IControl
			{
			public:
				ILabel(const ILabel&) { Throw <ptr<NotSupportException> >(); }
				BMETHODS(PLabel, ILabel)
				//默认的按钮过程处理函数指针
				static LONG_PTR pfun;
				ILabel(HWND hParent)
					:IControl()
				{
					SetHandle(Create(L"Label", Rect(0, 0, 160, 60), L"STATIC", WS_CHILD|WS_VISIBLE, 0, hParent, NULL));
					//替换默认过程
					pfun = GetWindowLongPtrW(GetHandle(), GWL_WNDPROC);
					if (pfun == 0)Throw<PWindowsException>(GetLastError());
					if (SetWindowLongPtrW(GetHandle(), GWL_WNDPROC, (LONG_PTR)&StaticWndProc) == 0)Throw<PWindowsException>(GetLastError());
				}

				//重写默认消息处理
				virtual LRESULT DefWndProc(MSG& message);

				//重写消息循环（可重写）
				virtual void WndProc(MSG& )
				{
				}
			};
			/**
			@brief 表示标签控件的代理*/
			class PLabel :public PControl
			{
			public:
				PMETHODS(PLabel, ILabel);
				//从父控件进行构造
				PLabel(PControl const &c) :PControl(new ILabel(c.Check()->GetHandle())){}

			};
		}
	}
}
